home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2292 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  47 lines

  1. Path: cs.usm.my!not-for-mail
  2. From: bahari@cs.usm.my (Bahari Belaton (Dr))
  3. Newsgroups: comp.lang.c
  4. Subject: Question on pointer-to-pointer-to-pointer-...
  5. Date: 20 Jan 1996 06:34:59 GMT
  6. Organization: School of Computer Science, USM.
  7. Message-ID: <4dq2ej$m3t@cssun.cs.usm.my>
  8. NNTP-Posting-Host: cssun.cs.usm.my
  9. X-Newsreader: TIN [UNIX 1.3 950824BETA - USM Penang PL0]
  10.  
  11. Hi,
  12. Below is one of the question asked by my student about pointer-to-pointer in
  13. C - with a specific example on strtod() function. Can anyone help me explain
  14. this to my student. Especially on the important of pointer-to-pointer.
  15.  
  16. Thanks
  17.  
  18. Bahari Belaton
  19.  
  20. =======================================================================
  21. Dear All,
  22.      I hope you can enlighthen me a bit.
  23. Query 1:
  24.      According to Deitel, the function prototype for strtod() is:-
  25.      double strtod(const char *nPtr, char **endPtr) and the function call is
  26. as follows :-
  27.      double d;
  28.      char *string = "51.2% are admitted";
  29.      char *stringPtr;
  30.  
  31.      d = strtod(string, &stringPtr);
  32.  
  33. The book says that &stringPtr is assigned the location of the first character
  34. after the converted value. How does the function do that?
  35.  
  36. I'm still confused with **endPtr. Why the **endPtr(pointer to a
  37. pointer) is used?(What is the significance of using a double pointer? Why
  38. not just *endPtr since the function assigned the address of first
  39. character of the string to &stringPtr. (what about***endPtr?
  40. How many pointers to pointer can we used?)
  41.  
  42. Thank you very much.
  43. Your student,
  44. LEE KENG TUNG csi36864@wira2.cs.usm.my
  45.  
  46. =================================
  47.